<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
	<!--<base href="http://test.youxiduo.com/iweb/2017_summer_activities/" />-->
	<base href="http://resource.youxiduo.com/special/shihou/promoter/3340v1/" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name = "format-detection" content = "telephone=no">
<meta name="viewport"  content="width=device-width,user-scalable=no">
<title>暑期狂欢派对</title>
<meta name="keywords" content="狮吼,狮吼直播,手游直播,双投屏直播" />
<meta name="description" content="狮吼 - 4亿手游玩家的直播平台、狮吼是游戏多旗下手游直播平台，支持双投屏直播的移动端平台，边玩边播，分享快乐！狮吼直播，随时随地录屏直播，语音弹幕独特玩法，各路主播游戏大神齐聚；电竞赛事、综艺娱乐、户外精彩，一切改变尽在 狮吼- 4亿手游玩家的直播平台。" />
<link rel="stylesheet" href="static/css/base.css" />
<link rel="stylesheet" href="static/css/style.css" />
<script type="text/javascript" src="static/js/config.js" ></script>

</head>
<body>

    <div class="wrap commonWrap">
        <!-- 评论 -->
        <img src="static/img/bg5.jpg"/> 
        <div class="common">
            <div class="commonTab">
                <img src="static/img/bg4.png"/>
                <div class="commonMenu">
                    <ul>
                        <li><img src="static/img/commomTabCurr1.png" /></li>
                        <li><img src="static/img/commomTab2.png" /</li>
                    </ul>
                </div>
            </div>
            <div class="bg">
                <div class="nav">
                    <input placeholder="快来留言吧~" id="content"/>
                    <a class="spend"><img src="static/img/spend.png"/></a>
                </div>
                <ul class="list">
                </ul>
                <a class="more"><img src="static/img/more.png"/></a>
                <div class="space"></div>
            </div>
            <p style=" width:90%; margin:10px auto;"><img src="static/img/fooder.png"/></p>
         </div>    
    </div>
    
    <!--<div class="commonIn">
    	<div class="commonInCont">
        	<input type="text" placeholder="快来留言吧~" id="content"/>
            <a class="btnFs" title="发送"></a>
        </div>
    </div>-->
    
	<div class="pop">请登录后再来参加活动吧~</div>
    
    
<script src="static/js/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="static/js/util.js" ></script>
<script language="JavaScript">
	var util;
	var config;
	var from_user_id;
	$(function()
	{
		util = new Util();
		config = new Config();
		from_user_id = util.getUrlParam('from_user_id');
		//util.pageSize = 1;  //供测试使用
		//最新和最热切换
		var currIndex = 0;
		$(".commonMenu li").on("click",function()
		{
			currIndex = $(this).index();
			$(".commonMenu li").each(function()
			{
				$(this).find("img").attr({"src":"static/img/commomTab"+($(this).index()+1)+".png"});
			});
			$(this).find("img").attr({"src":"static/img/commomTabCurr"+(currIndex+1)+".png"});	
			
			util.orderType = currIndex+1;
			util.uid = from_user_id;
			util.pageNum = 1;
			onloadFormuList();
		});
		$(".commonMenu li").eq(0).click();
		
		/*
		//弹出留言框
		$(".nav").on("click",function(){
			$(".commonIn").fadeIn();
			$(".commonWrap").css({"padding-bottom":"45px"});
		});
		*/
		//发送留言
		$('.spend').on('click', function(){
			if(from_user_id == "0"){
				window.location.href="shihoutv://route?jump_type=120";
				return;
			}
			util.content = $('#content').val();
			util.pulibshComment(config.publish_forum, config.check_gift);
			onloadFormuList();
		});
		
		//点击更多加载留言
		$('.more').on('click', function(){
			util.pageNum = util.pageNum + 1;
			onloadFormuList();
		});
		
		//用户是否送过礼物
		util.uid = from_user_id;
		util.checkSendGift(config.check_gift);
	});

	//点赞
	function fabulous(obj){
		if (from_user_id == "0"){
			window.location.href="shihoutv://route?jump_type=120";
	        return;
	    }
		util.id = $(obj).attr('data-id');
		util.uid = from_user_id;
		util.toUid = $(obj).attr('data-uid');
		util.fabulous(config.forum_fabulous, obj);
	}
	
	function onloadFormuList(){
		util.getFormList2(config.forum_list_url, function(res){
			if(res.errorCode == "0"){
				var list = res.result.list;
				var html = '';
				var item_user_ids = '';
				for (var i=0;i < list.length;i++) {
					var zanImg = 'zan';
					var item = list[i];
					var curr_uid = util.parseResult(item, 'uid');
					var create_time = util.parseResult(item, 'create_time');
					var create_time1 = create_time.split(' ')[0];
					var create_time1_array = create_time1.split('-');
					create_time1 = create_time1_array[1]+'-'+create_time1_array[2];
					var create_time2 = create_time.split(' ')[1];
					var create_time2_array = create_time2.split(':');
					create_time2 = create_time2_array[0]+':'+create_time2_array[1];
					create_time = create_time1+' '+create_time2;
					if(util.parseResult(item, 'fabulousStatus'))
						zanImg = 'yizan';
					html += '<li data-id="'+util.parseResult(item, 'id')+'" data-uid="'+curr_uid+'">'+
		                    '    <p class="listTitle"><span>'+util.parseResult(item, 'content')+'</span><a data-id="'+util.parseResult(item, 'id')+'" data-uid="'+curr_uid+'" onclick="fabulous(this);"><img src="static/img/'+zanImg+'.png"/></a></p>'+
		                    '    <p class="listFont">'+
		                    '        <a id="img-'+curr_uid+'" data-create-time="'+create_time+'"></a>'+
		                    '        <span>积赞：<em>'+util.parseResult(item, 'fabulous_count')+'</em></span>'+
		                    '    </p>'+
		                    '</li>';
		            item_user_ids += '&user_ids[]='+curr_uid;
				}
				if(util.pageNum == 1)
					$('.list').html(html);
				else
					$('.list').append(html);
				if(list.length < util.pageSize)
					$('.more').hide();
					
				//根据用户id取到用户信息并赋值到页面
				util.requestRemoteDataJson(config.user_batch+item_user_ids, {}, function(userResult){
					if(userResult.error == 0){
						var users = util.parseResult(userResult, 'data', 'users');
						for(var i = 0;i < users.length;i++){
							var user = users[i];
							var user_id = util.parseResult(user, 'id');
							var nick_name = util.parseResult(user, 'nick_name');
							var avatar = util.parseResult(user, 'avatar');
							var createTimeHtml = $('#img-'+user_id).attr('data-create-time'); 
							$('#img-'+user_id).html('<em><img src="'+avatar+'"/></em><i>'+nick_name+'</i>'+createTimeHtml);
						}
					}
				});
			}
			
		});
	}
</script>
	
</body>
</html>
